#ifndef _LINUX_GHASH_H_
#define _LINUX_GHASH_H_
#include <string.h>

#ifndef __USE_ISOC99
#define inline
#endif

struct _hashentry_t
{
    char     		 *key;
    void             *data;
    struct _hashentry_t *next;
};

struct _hashtable_t
{
    unsigned int      (*gethash)(char *);
    int               (*compare)(char *, char *);
    int               hashsize;
    int               count;
    struct _hashentry_t **hashlist;
};
typedef struct _hashtable_t   hashtable_t;

#define create_hashtable(hsize) \
         hash_create(strhash, strequal, hsize)

unsigned int strhash(char *src);
int strequal(char *k1, char *k2);




hashtable_t *hash_create(unsigned int (*keyfunc)(char *),
                       int (*comparefunc)(char *,char *),
                       int size);
void hash_free(hashtable_t *tab);
void hash_insert(char *key, void *data, hashtable_t *tab);
void hash_remove(char *key, hashtable_t *tab);
void * hash_value(char *key, hashtable_t *tab);
void hash_for_each_do(hashtable_t *tab, int (cb)(char *, void *));
int hash_count(hashtable_t *tab);

#endif
